# This repository contains all the code and data files required for replicating all the reported results in the BJPS paper: "When Parties Move to the Middle:\\The Role of Uncertainty",
# By Johannes Lindvall, David Rueda, and Haoyu Zhai.

# This file is written by: Haoyu Zhai (2022-12-03; updated on []). 
# This file contains basic information about the structure and usage of each file in the repo.

# Please contact Haoyu Zhai (haoyu.zhai@wzb.eu; haoyu.zhai@eui.eu) 
# If you encounter any issue or problem
# Or have any comments or suggestions

# All files with names starting with "R_" are code files (R scripts)
# All files with names starting with "RData_" are data files (.RData files)
# The two .dta files are raw data files downloaded from open-access external sources

# To replicate the analysis, download all code files and the .dta files (.RData files optional; they are produced from the codes and the raw data)
# Make sure all codes and data files are kept in the same local working directory; if not adjust the codes accordingly 
# The code files are ordered and named in the same order as the results are reported in the paper and supplement 
# Run the scripts in the order indicated in their filenames 
## I.e., R_0_1_make_measures.R -> R_0_2_make_data.R -> R_1_main_analysis.R -> R_2_appendix_ab.R -> R_2_appendix_c -> R_2_appendix_de.R
# This produces all the tables and graphs in the main paper and online supplement 

# Code file info:
## R_0_1_make_measures.R: creates the key measures (party, voter, and socio-economic and political variables).
## R_0_2_make_data.R: merges and cleans the measures into the final datasets for analysis (main and supplementary).
## R_1_main_analysis.R: produces all the results reported in the main text of the paper.
## R_2_appendix_ab.R: produces all the results reported in sections A & B of the online supplement.
## R_2_appendix_c.R: produces all the results reported in section C of the online supplement.
## R_2_appendix_de.R: produces all the results reported in sections D & E of the online supplement.

# Raw Data file info:
## MPDataset_MPDS2019b_stata14.dta: Manifesto Project Main Dataset (MARPOR; version 2019b), downloaded from https://manifesto-project.wzb.eu/datasets.
## CPDS-1960-2017-Update-2019.dta: Comparative Political Data Set (CPDS; version 2019), downloaded from https://www.cpds-data.org/.

# Data file info:
## RData_manifesto_oecd.Rdata: contains subset of MARPOR data for 34 OCED countries.
## RData_manifesto_mlr.RData: contains subset of MARPOR data for the main left and right parties in OECD countries.
## RData_measure_scale.RData: contains measures of policy positions for OECD countries.
## RData_measure_party.RData: contains measures of party platforms for OECD countries.
## RData_measure_voter.RData: contains measures of median voter preferences for OECD countries.
## RData_measure_marpor.RData: contains measures of party and other political factors for OECD countries. 
## RData_measure_cpds.Rdata: contains measures of socio-economic and other political factors for OECD countries.
## RData_data_core.Rdata: final dataset for the core sample of 20 OECD countries.
## RData_data_core2.Rdata: final dataset for the core sample of 20 OECD countries measured at the individual party (left, right) level.
## RData_data_final.Rdata: final dataset for the full sample of 34 OECD countries.
## RData_result_main.Rdata: core results from the main analysis (model objects).